package com.szy.bigevent.mapper;

import com.szy.bigevent.pojo.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface UserMapper {

    @Insert("insert into user(username, password, create_time, update_time) " +
            "values(#{username},#{md5String},now(),now())")
    void add(final String username, final String md5String);

    @Select("select * from user where username=#{username}")
    User findByUsername(final String username);

    @Select("select id, username, nickname from user")
    List<User> selectAll();

    @Update("update user set nickname=#{nickname}, email=#{email} where id=#{id}")
    void update(final User user);

    @Update("update user set user_pic=#{url} where id=#{id}")
    void updateAvatar(final String url, final Integer id);

    @Update("update user set password=#{md5String} where id=#{id}")
    void updatePwd(final String md5String, final Integer id);

}
